package cn.taketoday.live.config;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import cn.taketoday.live.service.SettingsService;

@Component
public class TimeTaskConfig {
  private SettingsService setService;
  private static final Logger LOGGER = LogManager.getLogger(TimeTaskConfig.class);

  @Scheduled(cron = "0 0 01,13 * * ?")
  public void updateSettings() {
    try {
      setService.updateSettings(GlobalData.centerSetConf);
    }
    catch (Exception e) {
      LOGGER.error("定时,检查配置文件出错");
    }
  }

  @Autowired
  public void setSetService(SettingsService setService) {
    this.setService = setService;
  }
}
